package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.huawei.appgallery.foundation.ui.css.CSSDeclaration;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.hwphy2d.physical.util.BarrierParameters;
import o.Logger;

public class RenderImageView extends ImageView implements RenderListener {
    private b ʼ;
    private float ˊ = 0.0f;
    private int ˋ = -1;
    private float ˎ = 0.0f;
    private float ˏ = BarrierParameters.FRICTION;
    private float ॱ = 0.0f;

    public interface b {
        boolean ˋ(CSSDeclaration cSSDeclaration);
    }

    public RenderImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public RenderImageView(Context context) {
        super(context);
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
    }

    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        this.ˊ = ((float) i2) * this.ˏ;
        this.ˎ = (float) i2;
        this.ॱ = (float) i;
        if (Logger.ˎ()) {
            Logger.ˏ("RenderImageView", "onSizeChanged viewHeight=" + this.ˎ + ",viewWidth=" + this.ॱ + ",renderHeight=" + this.ˊ);
        }
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (Logger.ˎ()) {
            Logger.ˏ("RenderImageView", "onDraw renderColor=" + this.ˋ);
        }
        if (this.ˋ != -1) {
            Shader linearGradient = new LinearGradient(0.0f, this.ˎ, 0.0f, this.ˎ - this.ˊ, this.ˋ, Color.argb(0, Color.red(this.ˋ), Color.green(this.ˋ), Color.blue(this.ˋ)), TileMode.MIRROR);
            Paint paint = new Paint(1);
            paint.setShader(linearGradient);
            canvas.drawRect(0.0f, this.ˎ - this.ˊ, this.ॱ, this.ˎ, paint);
        }
    }

    public void setRenderColor(int i) {
        this.ˋ = i;
    }

    public void setRenderScale(float f) {
        this.ˏ = f;
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        if (rule.getStyleDeclaration() == null) {
            return false;
        }
        CSSDeclaration styleDeclaration = rule.getStyleDeclaration();
        if (styleDeclaration == null) {
            return false;
        }
        if (this.ʼ != null) {
            return this.ʼ.ˋ(styleDeclaration);
        }
        return true;
    }

    public void setListener(b bVar) {
        this.ʼ = bVar;
    }
}
